<template>
  <view>
    <view class="home_tab">
      <view class="home_tab_title">
        <view class="title_inner"
          ><uni-segmented-control
            :current="current"
            :values="items.map((v) => v.title)"
            @clickItem="onClickItem"
            style-type="text"
            active-color="#d4237a"
          ></uni-segmented-control
        ></view>
        <view class="iconfont iconsearch"></view>
      </view>

      <view class="content">
        <view v-if="current === 0">
          <Recommend></Recommend>
        </view>
        <view v-if="current === 1">
          <Category></Category>
        </view>
        <view v-if="current === 2">
          <Album></Album>
        </view>
        
      </view>
    </view>
  </view>
</template>

<script>
import Album from "./home-album";
import Category from "./home-category";
import New from "./home-new";
import Recommend from "./home-recommend";
import { uniSegmentedControl } from "@dcloudio/uni-ui";
export default {
  data() {
    return {
      items: [
        { title: "推荐" },
        { title: "分类" },
       
        { title: "专辑" },
      ],
      current: 0,
    };
  },
  methods: {
    onClickItem(index) {
      if (this.current !== index.currentIndex) {
        this.current = index.currentIndex;
      }
    },
    
  },
  components: {
    Album,
    Category,
    New,
    Recommend,
    uniSegmentedControl,
  },
  onLoad(){
   
  }
};
</script>

<style lang="scss">
.home_tab {
  .home_tab_title {
    position: relative;
    .title_inner {
      width: 60%;
      margin: 0 auto;
    }
  }
}

.iconsearch {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 5%;
}
</style>
